package com.bawei.gmall.mock.utils;

import java.util.Date;
import java.util.Random;


/**
 * @ClassName RandomDate
 * @Description TODO
 * @Author mufeng_xky
 * @Date 2020/3/6 9:00
 * @Version V1.0
 **/
public class RandomDate {
    Long logDateTime = 0L;
    int maxTimeStep = 0;


    public RandomDate(Date startDate, Date endDate, int num) {
        Long avgStepTime = (endDate.getTime() - startDate.getTime()) / num;
        this.maxTimeStep = avgStepTime.intValue() * 2;
        this.logDateTime = startDate.getTime();
    }


    public Date getRandomDate() {
        int timeStep = new Random().nextInt(maxTimeStep);
        logDateTime = logDateTime + timeStep;
        return new Date(logDateTime);
    }
}

